Skip to content

Anthropic Token Counting#1749

Open
TimPansino wants to merge 10 commits into
mainfrom
feat-anthropic-token-counting
Open

Anthropic Token Counting#1749
TimPansino wants to merge 10 commits into
mainfrom
feat-anthropic-token-counting

Conversation

@TimPansino

Copy link
Copy Markdown
Contributor

Overview

  • Add token counting to Anthropic SDK for all LLM invocations.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 9 0 0 0.93s
✅ MARKDOWN markdownlint 7 0 0 0 1.37s
✅ PYTHON ruff 1039 0 0 0 1.05s
✅ PYTHON ruff-format 1039 0 0 0 0.4s
✅ YAML prettier 21 0 0 0 1.63s
✅ YAML v8r 21 0 0 6.8s
✅ YAML yamllint 21 0 0 0.7s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@codecov-commenter

codecov-commenter commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.68%. Comparing base (7bef5cc) to head (83f1567).

Files with missing lines Patch % Lines
newrelic/hooks/mlmodel_anthropic.py 76.00% 0 Missing and 6 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1749   +/-   ##
=======================================
  Coverage   81.67%   81.68%           
=======================================
  Files         215      215           
  Lines       26417    26438   +21     
  Branches     4171     4177    +6     
=======================================
+ Hits        21576    21595   +19     
+ Misses       3440     3434    -6     
- Partials     1401     1409    +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TimPansino TimPansino marked this pull request as ready for review June 2, 2026 22:26
@TimPansino TimPansino requested a review from a team as a code owner June 2, 2026 22:26
@mergify mergify Bot added the tests-failing Tests failing in CI. label Jun 8, 2026
@mergify mergify Bot removed the tests-failing Tests failing in CI. label Jun 9, 2026
)
)
if input_message_content:
response_prompt_tokens = token_count_callback(request_model, input_message_content)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should put the token count callback invocations inside of a specific try-except block so we can log out an error message with details if the customer's callback function failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants